package util

import (
	"path"
	"path/filepath"
	"strings"
)

func GetMediaFileInfo(fullName string, suffix string) (MediaFileInfo, bool) {
	temp := filepath.ToSlash(fullName)
	MFI := MediaFileInfo{
		FileFullName: fullName,                               // 文件名全路径
		Dir:          filepath.FromSlash(path.Dir(temp)),     // 文件所在目录
		FileName:     strings.Split(path.Base(temp), ".")[0], // 文件名
		Ext:          path.Ext(temp),                         // 扩展名
	}

	fileInfo, err := GetFileBaseInfo(fullName)
	if err != nil {
		return MFI, false
	}
	MFI.ModTime = fileInfo.ModTime()

	switch strings.ToLower(suffix) {
	case ".jpg":
		MFI.TokenTime, MFI.HasExif = ReadPhotoExitDateTime(fullName)
	case ".mov", ".mp4", ".avi", ".3gp":
		MFI.TokenTime, MFI.HasExif = ReadVideoFileDateTime(fullName)
	}

	return MFI, true
}
